# TODO: Add comment
# 
# Author: Forever
###############################################################################

library(sqldf)
data=read.csv("C:/myd03.csv")
data2 = sqldf("select tram,count(nam) from data group by tram;")
write.csv(data2,"C:/trammyd03.csv")

library(sqldf)
data=read.csv("C:/myd03.csv")
data2 = sqldf("select thang,count(nam) from data group by thang;")
write.csv(data2,"C:/thangmyd03.csv")

library(sqldf)
data=read.csv("C:/mod03.csv")
data2 = sqldf("select tram,count(nam) from data group by tram;")
write.csv(data2,"C:/trammod03.csv")

library(sqldf)
data=read.csv("C:/mod03.csv")
data2 = sqldf("select thang,count(nam) from data group by thang;")
write.csv(data2,"C:/thangmod03.csv")


library(sqldf)
data=read.csv("C:/mod2013.csv")
data2 = sqldf("select tram,thang,count(nam) from data group by tram,thang;")
write.csv(data2,"C:/trammod2013.csv")



#thang

library(sqldf)
data=read.csv("C:/mod.csv")
data2 = sqldf("select nam,thang,count(date1) from data group by nam,thang;")
write.csv(data2,"C:/thang.csv")

library(sqldf)
data=read.csv("C:/myd.csv")
data2 = sqldf("select nam,thang,count(date1) from data group by nam,thang;")
write.csv(data2,"C:/thang_myd.csv")

#tram

library(sqldf)
data=read.csv("C:/mod.csv")
data2 = sqldf("select nam,tram,count(date1) from data group by nam,tram;")
write.csv(data2,"C:/tram_mod.csv")

library(sqldf)
data=read.csv("C:/myd.csv")
data2 = sqldf("select nam,tram,count(date1) from data group by nam,tram;")
write.csv(data2,"C:/tram_myd.csv")

#tram _ thang
library(sqldf)
data=read.csv("C:/mod.csv")
data2 = sqldf("select nam,tram,thang,count(date1) as MOD from data group by nam,tram,thang;")
write.csv(data2,"C:/tram_thang_mod.csv")

library(sqldf)
data=read.csv("C:/myd.csv")
data2 = sqldf("select nam,tram,thang,count(date1) as MYD from data group by nam,tram,thang;")
write.csv(data2,"C:/tram_thang_myd.csv")


library(sqldf)
data=read.csv("C:/myd04.csv")
data2 = sqldf("select tram,count(nam) from data group by tram;")
write.csv(data2,"C:/trammyd04.csv")

library(sqldf)
data=read.csv("C:/myd04.csv")
data2 = sqldf("select thang,count(nam) from data group by thang;")
write.csv(data2,"C:/thangmyd04.csv")

library(sqldf)
data=read.csv("C:/mod04.csv")
data2 = sqldf("select tram,count(nam) from data group by tram;")
write.csv(data2,"C:/trammod04.csv")

library(sqldf)
data=read.csv("C:/mod04.csv")
data2 = sqldf("select thang,count(nam) from data group by thang;")
write.csv(data2,"C:/thangmod04.csv")
